<style>
.flow-files {width: 100%; height: auto;}
.flow-files li{display: inline-block; width: 114px; height: 105px; padding:10px; margin-bottom: 5px; text-align: center; background-color:#f5f5f5}
.flow-files img{max-width:114px; height:64px;}
.flow-files li p{margin-bottom: 5px;}
.flow-files .selected{background-color:#DDDDFF; border-radius: 5px 25px}
.flow-files .layui-elip{height:20px}
</style>
<div class="layui-row">
	<div class="layui-row">
		<blockquote class="layui-elem-quote">
			<div class="layui-btn-group">
				<button class="layui-btn layui-btn-sm #if(!folder) layui-btn-disabled #end" onclick="back();"><i class="layui-icon layui-icon-return"></i> 上一级</button>
				<button class="layui-btn layui-btn-sm" onclick="reload();"><i class="layui-icon layui-icon-refresh"></i> 刷新</button>
			</div>
			<div class="layui-btn-group">
				<button class="layui-btn layui-btn-sm layui-btn-warm" id="ID_btn_upload"><i class="layui-icon layui-icon-upload"></i> 上传</button>
				<button class="layui-btn layui-btn-sm layui-btn-normal" onclick="newFolder();"><i class="layui-icon layui-icon-add-1"></i> 新文件夹</button>
				<button class="layui-btn layui-btn-sm layui-btn-danger" onclick="delFiles();"><i class="layui-icon layui-icon-delete"></i> 删除勾选项</button>
			</div>
			<div class="layui-btn-group" style="float: right; margin-right: 20px">
				<button class="layui-btn layui-btn-sm layui-btn-normal ck-select-btn" onclick="ckSelectFiles();" style="display: none;"><i class="layui-icon layui-icon-ok"></i> 选择变色项</button>
			</div>
			<div class="layui-btn-group"></div>
			<div class="layui-btn-group">
				<p class="layui-breadcrumb">
					<a href="javascript:getList('go');">根</a>
				#set(folerPath = "")
				#for(folder : folders)
					#set(folerPath = folerPath + "/" + folder)
					#if(for.last)
					<a><cite>#(folder)</cite></a>
					#else
					<a href="javascript:getList('go', '#(folerPath)');">#(folder)</a>
					#end
				#end
				</p>
			</div>
		</blockquote>
	</div>
</div>
<div class="layui-row layui-form">
	<ul class="flow-files" id="ID_files">
		<li>
			<p>
				<a href="javascript:#if(folder)getList('back', '#(folder)')#end;">
					<img lay-src="#(ctx)/manage/_assets/images/icon/folder_96.png">
				</a>
			</p>
			<p><input type="checkbox" lay-skin="primary" title=".."></p>
			<p class="layui-elip" style="color:#if(folder) blue#else gray#end;">[上一级]<p>
		</li>
	#for(file : files)
		#if(file.type == "folder")
		<li>
			<p>
				<a href="javascript:getList('go', '#(folder)/#(file.name)');">
					<img lay-src="#(ctx)/manage/_assets/images/icon/folder_96.png">
				</a>
			</p>
			<p><input type="checkbox" lay-skin="primary" title="（#(file.size) 项）" file="#(file.name)"></p>
			<p class="layui-elip">#(file.name)</p>
		</li>
		#else if(accept == "" || (accept != "" && file.type == accept))
		<li>
			<p title="#(file.name)" class="jfsa-file">
				<a>
					<img lay-src='#if(file.type == "image") #(ctx)/upload/#(folder)/#(file.name + "?" + file.length) #else #(ctx)/manage/_assets/images/icon/#(file.type)_96.png #end'>
				</a>
			</p>
			<p><input type="checkbox" lay-skin="primary" title="#(file.size)" file="#(file.name)"></p>
			<p class="layui-elip">#(file.name)</p>
		</li>
		#else
		#end
	#end
	</ul>
</div>

<script>
$("#ID_folder").val("#(folder)");
upload.render({
	elem : '#ID_btn_upload',
	url : '#(ctx)/manage/files/ajaxUpload?folder=' + $("#ID_folder").val(),
	size : 2048,
	multiple : true,
	accept : "file",
	before : function(obj) {
		layer.load(1);
	},
	done : function(res) {
		if (res.code == 0) {
			layer.msg("操作成功");
			reload();
		} else {
			layer.alert("操作失败：" + res.msg);
		}
		layer.closeAll('loading');
	},
	error : function(res) {
		layer.alert("操作失败！");
		layer.closeAll('loading');
	}
});

$(".jfsa-file").click(function(){
	selectedItem($(this).parent());
});

if($("#ID_CKEditor").val() != ""){
	$(".ck-select-btn").show();
}
</script>
